<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            padding-bottom: 800px;
            padding-left: 30px;
        }
        .select-two{
            position: relative;
            display: inline-block;
        }
        .select-two input{
            width: 240px;
            outline: none;
            padding: 8px 4px;
        }
        .select-two ul{
            list-style: none;
            margin: 0px;
            padding: 0px;
            position: absolute;
            left: 0px;
            width: 100%;
            transform: translate(0,10px);
            box-shadow: 0 0 10px #999;
            border-radius: 8px;
            overflow: hidden;
            padding: 4px 0px;
            /* display: none; */
        }
        .select-two ul li{
            padding: 4px 20px;
            cursor: pointer;
        }
        .select-two ul li:hover{
            background-color: rgba(0, 0, 255, 0.1);
        }
        .select-two ul .tip{
            text-align: center;
            color: #999;
        }
        .select-two ul .tip:hover{
            background-color: unset;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="select-two">
            <input type="text" v-model="word" @focus="flag=true" @blur="flag=false">
            <ul v-show="flag">
                <li class="tip" v-show="filterArr.length==0">查无匹配项</li>
                <li v-for="item in filterArr" @mousedown=" word=item ">{{ item }}</li>
            </ul>
        </div>
    </div>
    <script src="../assets/mock/mock-min.js"></script>
    <script type="module">
        import { createApp } from "../assets/vue3/vue.esm-browser.js"
        createApp({
            data(){
                return {
                    word:"",
                    arr:Mock.mock({
                        "arr|20":[
                            "@word"
                        ]
                    }).arr,
                    flag:false
                }
            },
            computed:{
                filterArr(){
                    return this.arr.filter( item => item.indexOf(this.word)!=-1 )
                }
            },
            methods:{
                
            }
        }).mount("#app")
    </script>
</body>
</html>